﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain.zmc;
using MyMES.Error;
using MyMES.Read.API.Application.Commends.Departments;

namespace MyMES.Read.API.Controllers.ZMC.Departments
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    // [Authorize]
    public class DepartmentsController : ControllerBase
    {
        private readonly IMediator mediator;

        public DepartmentsController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 获取部门列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 

        [HttpGet]

        public async Task<APIResult<List<Department>>> GetDepartment([FromQuery] GetDepartmentCommends request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
    }
}
